package com.yizhu.zczy.system.controller;

import java.util.Arrays;
import java.util.Map;


import com.yizhu.zczy.common.utils.PageUtils;
import com.yizhu.zczy.common.utils.R;
import com.yizhu.zczy.system.vo.PermissionsVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.yizhu.zczy.system.entity.RolesEntity;
import com.yizhu.zczy.system.service.RolesService;




/**
 * 角色表
 *
 * @author guoyz
 * @email guoyz@mail.com
 * @date 2021-06-24 18:31:46
 */
@RestController
@RequestMapping("system/roles")
@Api("角色信息")
public class RolesController {
    @Autowired
    private RolesService rolesService;





    /**
     * 列表
     */
    @GetMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = rolesService.queryPage(params);
        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{roleId}")
    public R info(@PathVariable("roleId") Integer roleId){
		RolesEntity roles = rolesService.getById(roleId);

        return R.ok().put("roles", roles);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("system:roles:save")
    public R save(@RequestBody RolesEntity roles){
		rolesService.save(roles);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("system:roles:update")
    public R update(@RequestBody RolesEntity roles){
		rolesService.updateById(roles);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("system:roles:delete")
    public R delete(@RequestBody Integer[] roleIds){
		rolesService.removeByIds(Arrays.asList(roleIds));

        return R.ok();
    }

}
